package com.charity.rest.controller.manage.system;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.charity.system.service.IUserService;
import com.charity.system.vo.model.UserModel;
import com.charity.system.vo.query.UserPageQuery;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/manage/user")
@RequiredArgsConstructor
public class UserController {

    private final IUserService userService;

    @PostMapping("/getPageList")
    public IPage<UserModel> getPageList(@RequestBody UserPageQuery req) {
        return userService.getPageList(req);
    }

    @GetMapping("/{id}")
    public UserModel getUserById(@PathVariable("id") Long id) {
        return userService.getUserById(id);
    }

    @PostMapping("/createUser")
    public Long createUser(@RequestBody UserModel model) {
        return userService.createUser(model);
    }

    @PostMapping("/updateUser")
    public void updateUser(@RequestBody UserModel model) {
        userService.updateUser(model);
    }

    @DeleteMapping("/{id}")
    public void deleteUser(@PathVariable Long id) {
        userService.deleteUser(id);
    }
}
